Xbasic

Array dump_properties Method

Syntax

dim String as C = <array>.dump_properties(C format[,C filter])

Arguments

formatCharacter

Defines the array properties to print and how to format the output. The format is defined as: "Prop1 [| Prop2...[| PropN ]]][| *Index " where Prop1 ... PropN are the names of array properties. *Index is an optional argument that prints the index of the array element.

filterCharacter

Default = all elements. A logical expression that uses any of the array properties.

Returns

StringCharacter

Returns a CR-LF delimited list of formatted strings containing the values defined by the format argument.

Description

Dump the properties array to a string of newline separated entries.

Discussion

The <array>.dump_properties() method creates a CR-LF delimited string of a single dimensional property array's contents. This is the reverse of the <array>.initialize_properties() method.

Used in conjunction with the <array>.initialize_properties() method, this method can be used to copy one array's contents to another.

The format defines which of the array's properties you want to dump, and the format of the output string. For example, the format "Name|Age|Position" will create a CR-LF delimited string with the name, age, and position properties of an array with the "|" character between elements. Each element in the format can be followed by an optional ":*" directive. This causes Alpha Anywhere to dump out that array element with a one character prefix indicating the element's data type.

The optional filter allows you to specify a filter expression that involves any of the array properties.

Assume an array "A" contains the following elements:

Element

Name

Age

Birthday

A[1]

Fred

20

12/3/1980

A[2]

Tom

40

11/3/1960

A[3]

Joanne

50

4/1/1950

? a.dump_properties("Name|Age|BirthDay")
= "Fred|20|12/03/1980
Tom|40|11/03/1960
Joanne|50|04/01/1950"

? a.dump_properties("Name:*|Age:*|BirthDay:*")
= "CFred|N20|D12/03/1980
CTom|N40|D11/03/1960
CJoanne|N50|D04/01/1950"

? a.dump_properties("Name","Age>20")
= "Tom
Joanne"
dim a[5] as p 

 a.initialize_properties("name,state",<<%str% 
 cian,NY 
 eavan,NY 
 selwyn,MA 
 lachlan,NY 
 richard,MA 
 %str%) 

 ? a.dump_properties("name|*index","state='NY'") 
 = cian|1 
 eavan|2 
 lachlan|4 

 ? a.dump_properties("name|*index","state='MA'") 
 = selwyn|3 
 richard|5